<%-- 
    Document   : daftar_user
    Created on : Jan 1, 2012, 3:25:43 AM
    Author     : sha
--%>

<%@page import="entities.Propinsi"%>
<%@page import="java.util.List"%>
<%@page import="entities.Cerita"%>
<%@page import="java.util.Iterator"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Cerita Unyil</title>
        <link rel="stylesheet" type="text/css" href="style/table.css" media="all">
        <style media="all" type="text/css">@import "css/all.css";</style>
    </head>
    
    <body>
        <div id="page">
            <div id="header">
                <div class="background">
                    <% Propinsi propinsi = (Propinsi) request.getAttribute("propinsi");%>
                    <% String username = (String)session.getAttribute("username");%>
                    
                    <% String linkback = "";
                    
                    if(propinsi.getId() == 27 || propinsi.getId() == 28 || propinsi.getId() == 29){                      
                        linkback = "banus/banus.jsp";                               
                    }else if(propinsi.getId() == 10 ||
                            propinsi.getId() == 11 ||
                            propinsi.getId() == 12 ||
                            propinsi.getId() == 13 ||
                            propinsi.getId() == 14 ||
                            propinsi.getId() == 15){
                        linkback = "jawa/jawa.jsp";
                    }else if(propinsi.getId() == 16 ||
                            propinsi.getId() == 17 ||
                            propinsi.getId() == 18 ||
                            propinsi.getId() == 19 ||
                            propinsi.getId() == 20){
                        linkback = "kalimantan/kalimantan.jsp";
                    }else if(propinsi.getId() == 30 ||
                            propinsi.getId() == 31 ||
                            propinsi.getId() == 32 ||
                            propinsi.getId() == 33){
                        linkback = "papua/papua_home.jsp";
                    }else if(propinsi.getId() == 21 ||
                            propinsi.getId() == 22 ||
                            propinsi.getId() == 23 ||
                            propinsi.getId() == 24 ||
                            propinsi.getId() == 25 ||
                            propinsi.getId() == 26){
                        linkback = "sulawesi/sulawesi.jsp";
                    }else if(propinsi.getId() == 1 ||
                            propinsi.getId() == 2 ||
                            propinsi.getId() == 3 ||
                            propinsi.getId() == 4 ||
                            propinsi.getId() == 5 ||
                            propinsi.getId() == 6 ||
                            propinsi.getId() == 7 ||
                            propinsi.getId() == 8 ||
                            propinsi.getId() == 9){
                        linkback = "sumatera/sumatera.jsp";    
                    }    
                    %>
                                                
                    <% List<Cerita> listcerita = (List<Cerita>) request.getAttribute("list_cerita");%>
                    <% Cerita cerita;%>
                    <% Iterator<Cerita> iterator = listcerita.iterator();%>
                    <h1><a href="#">CeritaUnyil</a></h1>
                    <ul>
                            <li class="active"><a href="home">Home</a></li>
                            <li><a href="<%=linkback%>">Kembali</a></li>
                            <li><a href="logout">Logout</a></li>
                    </ul>
                </div>
            </div>
    <div id="content" align="center">
       <table id="rounded-corner">
            <thead>
                <tr>
                    <th colspan="4"><h2><center>Daftar Cerita di Propinsi <%=propinsi.getNama_propinsi()%></center></h2></th>
                </tr>
                <tr>
                    <th width="187" class="" scope="col">Judul Cerita</th> 
                    <th width="20" class="" scope="col"></th>  
                    <th width="20" class="" scope="col"></th>  
                    <th width="20" class="" scope="col"></th>  
                </tr>
            </thead>
            <tbody>
                <% while (iterator.hasNext()) {
                cerita = iterator.next();%>
                <tr>
                    <td><%=cerita.getJudul_cerita()%></td> 
                    <td>
                        <a href="LihatCerita?cerita=<%=cerita.getId()%>">lihat</a>
                    </td> 
                        <% if(username.equals("admin")){%>
                            <td><a href="EditCerita?cerita=<%=cerita.getId()%>">edit</a></td>
                            <td><a href="ProsesDeleteCerita?cerita=<%=cerita.getId()%>">delete</a></td>
                        <%;}else{%>
                            <td></td>
                            <td></td>   
                        <%;}%>
                </tr>
                <%}%>
                
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4"><em><a href="InputCerita?propinsi=<%=request.getParameter("propinsi")%>">Tambah Cerita</a></em></td>
                </tr>                
            </tfoot>
        </table> 
    </div>
        </div>    
    </body>
</html>
